<%@ page import="cn.czxy.share.domain.ShareFile" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/4/13 0013
  Time: 09:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%


%>

<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
    <script src="${pageContext.request.contextPath}/js/jquery-1.12.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
</head>
<body>
    <%--<form>
        <input type="text" name="searchName">
        <input type="submit">
    </form>--%>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="<%=request.getContextPath()%>/share?method=shareFileList&userName=${user.userName}">我的共享</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li class="dropdown">
                        <a href="<%=request.getContextPath()%>/share?method=shareFileList&userName=${uName}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">其他用户共享 <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <c:forEach items="${shareUlist}" var="uName" varStatus="vs">
                            <li>
                                <a href="<%=request.getContextPath()%>/share?method=shareFileList&userName=${uName}">${uName}</a>
                            <li>
                                <li role="separator" class="divider"></li>
                            </c:forEach>
                        </ul>
                    </li>
                </ul>
                <form class="navbar-form navbar-left" role="search" action="<%=request.getContextPath()%>/share" method="post">
                    <input type="hidden" name="method" value="viewPersonalShareFile">
                    <div class="form-group">
                        <input type="text"  placeholder="请输入私密口令" name="address" class="form-control" >
                    </div>
                   <button type="submit" class="btn btn-default">Open</button>
                </form>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>

    <%--<div class="btn-group" role="group" aria-label="...">
        <span class="btn-group" role="group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                其他用户共享
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <c:forEach items="${shareUlist}" var="uName" varStatus="vs">
                    <li>
                        <a href="<%=request.getContextPath()%>/share?method=shareFileList&userName=${uName}">${uName}</a>
                    <li>
                </c:forEach>
            </ul>
        </span>
    </div>--%>


    <%--<span>
        <c:forEach items="${shareUlist}" var="uName" varStatus="vs">
            <a href="<%=request.getContextPath()%>/share?method=shareFileList&userName=${uName}">${uName}</a>
        </c:forEach>
    </span>--%>
    <%--<div>
        <a href="<%=request.getContextPath()%>/share?method=shareFileList&userName=${user.userName}">我的共享</a>
    </div>--%>


    <table class="table">
        <tr>
            <td>
                文件名
            </td>
            <td>
                分享者
            </td>
            <td>
                分享时间
            </td>
            <td>
                有效期
            </td>
            <td>
                查看
            </td>
            <td>
                操作
            </td>

        </tr>
        <c:forEach items="${sfList}" var="sf" varStatus="vs">
            <tr>
                <td>
                    ${sf.fileName}
                </td>
                <td>
                    ${sf.userLoginName}
                </td>
                <td>
                    <%
                        ShareFile sf = (ShareFile) pageContext.findAttribute("sf");
                        Date date = new Date(sf.getShareDate());
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
                        pageContext.setAttribute("shareTimeOnJSP",sdf.format(date));
                    %>
                    ${shareTimeOnJSP}
                </td>
                <td>
                    有效期:
                    <c:choose>
                        <c:when test="${sf.liveTime == 1000*60*60*24*7}">
                            7天
                        </c:when>
                        <c:when test="${sf.liveTime == 1000*60*60*24}">
                            1天
                        </c:when>
                        <c:when test="${sf.liveTime == 1000*60*60*24*30}">
                            一个月
                        </c:when>
                        <c:otherwise>
                            永久
                        </c:otherwise>
                    </c:choose>
                </td>
                <td>
                    <div class="col-md-1" style="margin-top: 10px">
                        <a href="<%=request.getContextPath()%>/share?method=viewFile&en_filePath=${sf.en_filePath}&fileName=${sf.fileName}"><span class="glyphicon glyphicon-eye-open" aria-hidden="true" style="font-size: 20px"></span></a>
                    </div>
                </td>
                <td>
                    <div class="col-md-1" style="margin-top: 10px">
                        <c:choose>
                            <c:when test="${sf.userLoginName eq user.userName}">
                                <%--href="<%=request.getContextPath()%>/share?method=downLoadFile&filePath=${sf.en_filePath}&userLoginName=${sf.userLoginName}"--%>
                                <a href="<%=request.getContextPath()%>/share?method=deleteShareFile&filePath=${sf.en_filePath}&userLoginName=${sf.userLoginName}" onclick="return confirm('是否删除本条纪录')"><span class="glyphicon glyphicon-trash" aria-hidden="true" style="font-size: 20px"></span></a>
                            </c:when>
                            <c:otherwise>
                                <a href="<%=request.getContextPath()%>/share?method=downLoadFile&filePath=${sf.en_filePath}&userLoginName=${sf.userLoginName}"><span class="glyphicon glyphicon-circle-arrow-down" aria-hidden="true" style="font-size: 20px"></span></a>
                            </c:otherwise>
                        </c:choose>
                    </div>
                </td>
            </tr>
        </c:forEach>
    </table>
</body>
</html>
